<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>二审方案申报书</title>
<link rel="stylesheet" type="text/css" href="../css/blueprint/screen.css" media="screen, projection"/>
<link rel="stylesheet" type="text/css" href="../css/blueprint/plugins/buttons/screen.css" media="screen, projection"/>
<script type="text/javascript" src="../script/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../script/jquery.plugin.tablecross-0.1.js"></script>
<script type="text/javascript" src="../script/jquery.plugin.pageit-0.1.js"></script>
<script type="text/javascript" src="../script/jquery.plugin.ajaxtip-0.1.js"></script>
<script type="text/javascript">
	var xzHtml = "";
	var kzHtml = "";
	var queryVO = {unit: "", xzCode: "", kzCode: ""};
	$(document).ready(function() {
		$("#planDataTable").ajaxProccessTip();
		getPlanData(queryVO, 1, 10);
		$("#pageBar").pageListener(getPlanData, queryVO);
		$("#QUERY_SELECT").change(function() {
	    	if ($(this).val() == "unit") {
	        	$("#QUERY_TD").html('<input type="text" value="" id="QUERY_CONDITION" />');
	    	}
	    	if ($(this).val() == "xz") {
	        	if (xzHtml == "") {
	        		$.getJSON("InitPlanXmxz.action", function(data) {
	        			var strArr = new Array();
	        			strArr.push('<select id="QUERY_CONDITION">');
	        			strArr.push('<option value="" selected>选择项目性质</option>');
	                    for (var l = 0; l < data.xmxzList.length; l++) {
	                    	strArr.push('<option value="' + data.xmxzList[l].xmxzCode + '">' + data.xmxzList[l].xmxzName + '</option>');
	                    }
	                    strArr.push('</select>');
	                    xzHtml = strArr.join('');
	                    $("#QUERY_TD").html(xzHtml);
	        		});
	        	} else {
	        		$("#QUERY_TD").html(xzHtml);
	        	}
	    	}
	    	if ($(this).val() == "kz") {
	        	if (kzHtml == "") {
	        		$.getJSON("InitPlanKz.action", function(data) {
	        			var strArr = new Array();
	        			strArr.push('<select id="QUERY_CONDITION">');
	        			strArr.push('<option value="" selected>选择矿种</option>');
	                    for (var l = 0; l < data.kzList.length; l++) {
	                    	strArr.push('<option value="' + data.kzList[l].kzCode + '">' + data.kzList[l].kzName + '</option>');
	                    }
	                    strArr.push('</select>');
	                    kzHtml = strArr.join('');
	                    $("#QUERY_TD").html(kzHtml);
	        		});
	        	} else {
	        		$("#QUERY_TD").html(kzHtml);
	        	}
	    	}
		});
		$("#QUERY_BUTTON").click(function() {
			var select = $("#QUERY_SELECT").val();
			var condition = $("#QUERY_CONDITION").val();
			if (select == "unit") {
				queryVO.unit = condition;
				queryVO.xzCode = "";
				queryVO.kzCode = "";
			}
			if (select == "xz") {
				queryVO.unit = "";
				queryVO.xzCode = condition;
				queryVO.kzCode = "";
			}
			if (select == "kz") {
				queryVO.unit = "";
				queryVO.xzCode = "";
				queryVO.kzCode = condition;
			}
			getPlanData(queryVO, 1, 10);
		});
	});
	
	function getPlanData(queryVO, pageIndex, pageSize) {
		$.ajax({
	        type: "post",
	        url: "ListSecondSubmittedPlan.action",
	        data: {"queryVO.unit": queryVO.unit, "queryVO.xzCode": queryVO.xzCode, "queryVO.kzCode": queryVO.kzCode, "pageVO.pageIndex": pageIndex, "pageVO.pageSize": pageSize},
	        dataType: "json",
	        success: function(data) {
	        	if (data == null) {
                    alert('非法的请求，请确认你是否有权限执行该操作，请重新登录。');
                    window.parent.location.href="../j_spring_security_logout";
                    return;
                }
	    	    var strArr = new Array();
	            for (var i = 0; i < data.planList.length; i++) {
	                strArr.push('<tr>');
	                strArr.push('<td>' + data.planList[i].registerid + '</td>');//项目登记号
	                strArr.push('<td>' + data.planList[i].prjUnit + '</td>');//项目单位
	                strArr.push('<td>' + data.planList[i].prjName + '</td>');//项目名称
	                strArr.push('<td>' + data.planList[i].prjXmxzName + '</td>');//项目性质
	                strArr.push('<td>' + data.planList[i].prjXmgm + '</td>');//项目规模
	                strArr.push('<td>' + data.planList[i].prjKzName + '</td>');//矿种
	                strArr.push('<td>' + data.planList[i].prjKcfsName + '</td>');//开采方式
                    strArr.push('<td>' + nameFazt(data.planList[i].prjFaztcode) + '</td>');//方案状态
                    strArr.push('<td>');
                    strArr.push('<a href="SubmittedPlanDetailPre.action?planId=' + data.planList[i].prjPkid + '" target="MainFrame" class="button"><img src="../css/blueprint/plugins/buttons/icons/table.png" alt=""/>明细</a>');
                    if (data.planList[i].prjFaztcode == "2") {
                    	strArr.push('<input type="hidden" class="hiddenPlanId" value="' + data.planList[i].prjPkid + '" /><button type="button" class="pass-button"><img src="../css/blueprint/plugins/buttons/icons/tick.png" alt=""/>通过</button><button type="button" class="reject-button"><img src="../css/blueprint/plugins/buttons/icons/cross.png" alt=""/>返修</button><button type="button" class="delete-button"><img src="../css/blueprint/plugins/buttons/icons/delete.png" alt=""/>删除</button>');//操作
                    }
                    strArr.push('</td>');
	                strArr.push('</tr>');
	            }
	            $("#planDataBody").html(strArr.join(''));
	            $("#planDataBody").tablecross('', 'odd', 'over');
	            $("#pageBar").pageRender(data.pageVO.pageIndex, data.pageVO.pageSize, data.pageVO.pageNum);
	            operation();
	        }
		});
	}
    function nameFazt(code) {
        if (code == "1") {
            return "编辑中";
        } else if (code == "2") {
            return "已提交";
        } else {
            return "";
        }
    }
	function operation() {
	    $(".pass-button").click(function() {
	        $.getJSON("PassSubmittedPlan.action", {"planId": $(this).siblings(".hiddenPlanId").val()},
	            function(data) {
	                if (data.optRet == "success") {
	                    window.location.href = "ListSubmittedPlan2.html";
	                } else {
	                    $("#optRet").text("操作不成功，请重试");
	                }
	            }
	        );
	    });
	
	    $(".reject-button").click(function() {
	        $.getJSON("RejectSubmittedPlan.action", {"planId": $(this).siblings(".hiddenPlanId").val()},
	            function(data) {
	                if (data.optRet == "success") {
	                    window.location.href = "ListSubmittedPlan2.html";
	                } else {
	                    $("#optRet").text("操作不成功，请重试");
	                }
	            }
	        );
	    });
	
	    $(".delete-button").click(function() {
	        if (confirm("确定要删除方案吗?")) {
	            $.getJSON("DeleteSubmittedPlan.action", {"planId": $(this).siblings(".hiddenPlanId").val()},
	                function(data) {
	                    if (data.optRet == "success") {
	                        window.location.href = "ListSubmittedPlan2.html";
	                    } else {
	                        $("#optRet").text("操作不成功，请重试");
	                    }
	                }
	            );
	        }
	    });
	}
</script>
<style type="text/css">
tr.odd td {
    background: #ecf6fc;
}
</style>
</head>
<body>
<table style="margin-bottom: 10px" width="98%" align="center" cellpadding="0" cellspacing="0">
	<tr>
        <td width="15" style="padding: 0px" align="left">
		    <select id="QUERY_SELECT">
		        <option value="unit">项目单位</option>
		        <option value="xz">项目性质</option>
		        <option value="kz">矿种</option>
		    </select></td>
    	<td width="15" id="QUERY_TD"><input type="text" value="" id="QUERY_CONDITION"/></td>
    	<td align="left"><button type="button" id="QUERY_BUTTON"><img src="../css/blueprint/plugins/buttons/icons/magnifier.png" alt=""/>查询</button></td>
    </tr>
</table>
<table id="planDataTable" class="tablesorter" style="margin-top: 0px" width="98%" align="center" cellpadding="2" cellspacing="2">
    <thead>
        <tr>
            <th width="8%">项目<br/>登记号</th>
            <th width="12%">项目单位</th>
            <th width="12%">项目名称</th>
            <th width="6%">项目<br/>性质</th>
            <th width="6%">项目<br/>规模</th>
            <th width="6%">矿种</th>
            <th width="6%">开采<br/>方式</th>
            <th width="6%">方案<br/>状态</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody id="planDataBody">
    </tbody>
    <tbody id="pageBar">
        <tr>
            <td colspan="9" nowrap="nowrap" width="100%">
                <table>
                    <tbody>
                        <tr>
                            <td height="25"><button type="button" class="first-page"><img src="../css/blueprint/plugins/buttons/icons/resultset_first.png" alt=""/></button></td>
                            <td><button type="button" class="previous-page"><img src="../css/blueprint/plugins/buttons/icons/resultset_previous.png" alt=""/></button></td>
                            <td width="20%"><span class="page-index-selector" style=""></span></td>
                            <td><button type="button" class="next-page"><img src="../css/blueprint/plugins/buttons/icons/resultset_next.png" alt=""/></button></td>
                            <td><button type="button" class="last-page"><img src="../css/blueprint/plugins/buttons/icons/resultset_last.png" alt=""/></button></td>
                            <td><select class="page-size-selector">
                                    <option value="10" selected="selected">10</option>
                                    <option value="20">20</option>
                                    <option value="30">30</option>
                                </select></td>
                            <td width="80%">&nbsp;</td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>
</body>
</html>